package handler

import (
	"context"
	"errors"
	"server/basic/dao"
	"server/basic/proto/consultation"
)

type ConsultationServer struct {
	consultation.UnimplementedConsultationServerServer
}

func (s *ConsultationServer) PatientAdd(_ context.Context, req *consultation.PatientReq) (*consultation.PatientResp, error) {
	add, err := dao.ConsultationAdd(req.Name, req.Url, req.UserId, req.Type, req.Content)
	if err != nil {
		return nil, err
	}
	if add.Id == 0 {
		return nil, errors.New("信息填写错误")
	}

	return &consultation.PatientResp{PatientId: int32(add.Id)}, nil
}
